package com.yq.master.controller;

import com.yq.core.base.service.BaseService;
import com.yq.core.service.CodStatusService;
import com.yq.master.annotation.AzerothAutowired;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.ServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;


/**
 * 
 * 文件名: 代码
 * 创建人: yinquan
 * 创建日期: 2017-03-21 15:42:34
 * 描  述: 代码表操作
 * 版本号： 1.0
 */
@Controller
@RequestMapping(value = "/cod/status")
public class CodStatusController extends BaseController {
    private static Logger logger = LoggerFactory.getLogger(CodStatusController.class);

    @AzerothAutowired
    public CodStatusService codCodeService;

    protected BaseService getServcie() {
        return codCodeService;
    }

    protected String getJumpData() {
        return "";
    }

    /** 获取代码 **/
    @RequestMapping(value = "method")
    @ResponseBody
    public Object insertTopExec(Model model, ServletRequest request) {
        try{
            String method = request.getParameter("method");
            if(StringUtils.isNotBlank(method)){
                List<Map<String, Object>> list = codCodeService.getCodeList(method);
                return list;
            }
        }catch(Exception e){
            logger.error("CodCodeController method is error!", e);
        }
        return new ArrayList<Map<String, Object>>();
    }
}
